<template>
  <div class="news-detail">
    <!-- <el-button>I am ElButton</el-button> -->
    <div class="banner container-fuild text-center">新闻动态</div>

    <div v-if="getDataList" class="col-xs-12 col-sm-12 col-md-9 news-c-box">
      <div class="c-box">
        <h2>{{ getDataList.contentTitle }}</h2>
        <div class="remark">
          <span>时间：{{ getDataList.xwsj }}</span>
          <span>作者：{{ getDataList.author }}</span>
        </div>
        <!-- <div v-html="getDataList.content" class="content-box"></div> -->
        <div class="ql-container ql-snow">
          <div class="ql-editor">
            <div v-html="getDataList.content" class="content-box"></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from "vue";
import { useRoute, useRouter } from 'vue-router'
import axios from '../utils/axios';
const route = useRoute();

const getDataList = ref(null);

const fetchData = async () => {
  let id = route.params.id;
  const res = await axios.get(`/gwht/gw/xwdt/${id}`);

  getDataList.value = res.data;
};

onMounted(fetchData);
</script>

<style lang="less" scoped>
.banner {
  color: #fff;
  font-size: 30px;
  height: 150px;
  line-height: 150px;
  background-image: url('../assets/img/banner_2.jpg');
  background-repeat: no-repeat;
  background-size: cover;
  background-attachment: scroll;
  background-position: center center;
}

/deep/.ql-container.ql-snow {
  border: 0px solid #000;
}

/deep/.ql-editor {
  .ql-align-center,
  p,
  div {
    width: 100%;
    // background-color: red;

    img {
      display: inline-block;
      width: 40vw !important;
    }
  }

}

// /deep/img {
//   width: 40vw !important;
//   // display: none;
// }


.news-detail {
  .news-c-box {
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .c-box {
    width: 72%;
    margin: 10px 0;
  }

  // div,
  // p {
  //   width: 100%;
  //   display: flex;
  //   flex-direction: column;
  //   align-items: center
  // }

  .content-box {
    margin: 20px 0 50px;
  }


  h2 {
    text-align: center;
    font-weight: 600;
  }

  .remark {
    display: flex;
    flex-direction: row;
    justify-content: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);

    span {
      padding: 12px 36px;
      color: rgba(0, 0, 0, 0.5);
    }
  }
}
</style>